# This program will construct a tree, then serialize
# it to disk using the python module "pickle"

from binaryTree import *
import pickle

if __name__ == "__main__":
# create the binary tree
    BTree = CBOrdTree()
# add the root node
    root = BTree.addNode(0)
# ask the user to insert values
    for i in range(0, 5):
        data = int(raw_input("insert the node value nr %d: " % i))
# insert values
        BTree.insert(root, data)
    print
    
    BTree.printTree(root)
    print
    BTree.printRevTree(root)
    print
    data = int(raw_input("insert a value to find: "))
    if BTree.lookup(root, data):
        print "found"
    else:
        print "not found"
        
    print BTree.minValue(root)
    print BTree.maxDepth(root)
    print BTree.size(root)
    
    serializedFile = open('myIndex.dat', 'wb')
    pickle.dump(root, serializedFile)
    serializedFile.close()